﻿using System.Collections.Generic;
using System.Linq;

namespace NerdDinnerDataComponent
{
    public static class DinnerViewInfoMapper
    {
        public static IList<DinnerViewInfo> CreateFrom(IQueryable<Dinner> qry)
        {
           List<DinnerViewInfo> list = new List<DinnerViewInfo>();
            foreach (var dinner in qry)
            {
                list.Add(CreateFrom(dinner));
            }
            return list;
        }

        public static DinnerViewInfo CreateFrom(Dinner dinner)
        {

            return new DinnerViewInfo()
                       {
              
                           Description = dinner.Description,
                           DinnerId = dinner.DinnerID,
                           EventDate = dinner.EventDate,
                           Latitude = dinner.Latitude,
                           Longitude = dinner.Longitude,
                           Title = dinner.Title,
                           NumberOfRSVPs = dinner.RSVPs.Count
                       };
        }
    }
}